package com.zengdb.mybatis.service.impl;

import org.apache.ibatis.session.SqlSession;

import com.zengdb.mybatis.dao.DepartmentMapper;
import com.zengdb.mybatis.domain.Department;
import com.zengdb.mybatis.service.IDepartmentService;
import com.zengdb.mybatis.util.MyBatisUtil;

public class DepartmentServiceImpl implements IDepartmentService{

	@Override
	public void saveOne(Department dept) {
		SqlSession session = MyBatisUtil.openSession();
		DepartmentMapper dao = session.getMapper(DepartmentMapper.class);
		dao.saveOne(dept);
		session.commit();
		session.close();
	}

	@Override
	public Department selectOne(Long id) {
		SqlSession session = MyBatisUtil.openSession();
		DepartmentMapper dao = session.getMapper(DepartmentMapper.class);
		Department dept = dao.selectOne(id);
		session.close();
		return dept;
	}

}
